package com.example.demo.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class DingshiTask {
    @Scheduled(fixedDelay = 1000 * 5)//5秒执行一次
    public void task() throws InterruptedException {

        Thread.sleep(6000);
        System.out.println("定时任务" + System.currentTimeMillis());
    }
    private Integer count3 = 1;
    @Scheduled(cron = "0 0 12 * * ?")
    public void scheduledTask3(){
        System.out.println(String.format("cron第%s次执行",count3++));
    }
}